/**
 * 
 */
package com.thor.palmmall.rest.sales.input.converter;

import java.util.ArrayList;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.sales.input.AProductsParam;
import com.thor.palmmall.spi.basic.SProductsParam;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class SProductsParamConverter implements Converter<AProductsParam, SProductsParam> {

  public static SProductsParamConverter getInstance() {
    if (instance == null)
      instance = new SProductsParamConverter();
    return instance;
  }

  private static SProductsParamConverter instance;

  private SProductsParamConverter() {
  }

  @Override
  public SProductsParam convert(AProductsParam source) {
    if (source == null) {
      return null;
    }
    SProductsParam target = new SProductsParam();
    target.setContract(UCN.newInstance(source.getContract()));
    target.setSaleDate(source.getSaleDate());
    target.setStores(new ArrayList<String>());
    target.getStores().addAll(source.getStores());
    return target;
  }

}
